package com.jfree.common;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author wangjian
 * @date 2019/10/14 14:44
 */
public class StuLam {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<Student>();
        Student n1 = new Student("1", "NAME1", 0);
        Student n2 = new Student("2", "NAME1", 0);
        Student n3 = new Student("3", "NAME1", 0);
        Student n4 = new Student("4", "NAME1", 0);
        Student n5 = new Student("5", "NAME1", 0);
        list.add(n1);
        list.add(n2);
        list.add(n3);
        list.add(n4);
        list.add(n5);
        Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5, 4, 32, 2, 3);
        stream.distinct()
                .filter(v -> v > 2)
                //.map(v -> v - 2).skip(3)
                .peek(System.out::println)
                .sorted(Comparator.comparingInt(x -> x)).forEach(System.out::println);
         //       .forEachOrdered(System.out::println);
        Stream<List<Integer>> inputStream = Stream.of(
                Arrays.asList(1),
                Arrays.asList(2, 3),
                Arrays.asList(4, 5, 6)
        );
        Stream<Integer> outputStream = inputStream.
                flatMap((childList) -> childList.stream());
        outputStream.forEach(System.out::println);
        Stream<String> st= Stream.of("hello","world","heeq");
                 st.flatMap(v->Stream.of(v.split(""))).forEach(System.out::print);
                 list.stream().filter(v->v.getSex()>0).sorted(Comparator.comparing(Student::getId)).sorted().forEach(System.out::print);
        System.out.println("------------------------------------");
       list.stream().sorted(Comparator.comparing(Student::getId)).forEach(System.out::print);
    }


}
